class Solution
{
public:
    // 快速幂，注意溢出和取模时负数的问题
    int monkeyMove(int n)
    {
        constexpr int MOD = 1'0000'0000'7;
        long long result = 1;
        long long powOf2 = 2;
        while (n)
        {
            if (n & 1)
            {
                result *= powOf2;
                result %= MOD;
            }
            powOf2 *= powOf2;
            powOf2 %= MOD;
            n = n >> 1;
        }
        result += MOD - 2;
        result %= MOD;
        return result;
    }
};